package com.lol.controller;

import com.lol.model.EbUser;
import com.lol.service.LoginService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
public class LoginController {
    @RequestMapping("/to_login")
    public String toLogin(){
        return "login";
    }

    @Resource
    private LoginService loginService;
    @RequestMapping("/login")
    public String login(EbUser ebUser, HttpServletRequest request){
        //1.调用service完成登陆
        EbUser lgnUser = loginService.login(ebUser);
        //2.绑定数据到model--session：保存登录的用户信息
        request.getSession().setAttribute("lgnUser",lgnUser);
        //3.返回view--html
        return "redirect:/index/index";
    }
}
